package com.honey.mybatis.generator.condition;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Field;
import com.honey.compilation.java.Method;
import com.honey.core.compiler.CompilationException;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.core.types.JDKFullyQualifiedJavaType;
import com.honey.mybatis.generator.AbstractProduceJavaCompilation;
import com.honey.mybatis.generator.MybatisPlugin;
import com.honey.mybatis.generator.condition.field.DistinctField;
import com.honey.mybatis.generator.condition.field.GeneratedCriteriaField;
import com.honey.mybatis.generator.condition.field.OredCriteriaField;
import com.honey.mybatis.generator.condition.field.SortField;
import com.honey.mybatis.generator.condition.method.ClearMethod;
import com.honey.mybatis.generator.condition.method.ConstructorMethod;
import com.honey.mybatis.generator.condition.method.CreateCriteriaInternalMethod;
import com.honey.mybatis.generator.condition.method.CreateCriteriaMethod;
import com.honey.mybatis.generator.condition.method.GetOrderByMethod;
import com.honey.mybatis.generator.condition.method.GetOredCriteriaMethod;
import com.honey.mybatis.generator.condition.method.IsDistinctMethod;
import com.honey.mybatis.generator.condition.method.Or1Method;
import com.honey.mybatis.generator.condition.method.Or2Method;
import com.honey.mybatis.generator.condition.method.SetDistinctMethod;
import com.honey.mybatis.generator.condition.method.SetOrderByMethod;


/**
 *  生产Condition类
 * @author Administrator
 *
 */
public class ProduceCondition extends AbstractProduceJavaCompilation {
	
	public ProduceCondition(MybatisPlugin mybatisPlugin,IntrospectSchema introspectSchema, IntrospectSchemaColumn introspectSchemaColumn){
		super(mybatisPlugin,introspectSchema,introspectSchemaColumn);
	}
	
	@Override
	public AbstractJavaCompilation produceCompilation()throws CompilationException {
		AbstractJavaCompilation answer = 
			new ConditionClass( 
					mybatisPlugin, 
					introspectSchema, 
					introspectSchemaColumn 
			) 
			.createJavaCompilation();
		
		return answer;
	}

	@Override
	public Field[] produceFields() {
		Field[] answer = new Field[]{
			new SortField().createField(),
			new DistinctField().createField(),
			new OredCriteriaField().createField(),
			new GeneratedCriteriaField().createField(),
		};
		return answer;
	}

	@Override
	public Method[] produceMethods() {
		Method[] answer = new Method[]{
			new ConstructorMethod().createMethod(),
			new SetOrderByMethod().createMethod(),
			new GetOrderByMethod().createMethod(),
			new SetDistinctMethod().createMethod(),
			new IsDistinctMethod().createMethod(),
			new GetOredCriteriaMethod().createMethod(),
			new Or1Method().createMethod(),
			new Or2Method().createMethod(),
			new CreateCriteriaMethod().createMethod(),
			new CreateCriteriaInternalMethod().createMethod(),
			new ClearMethod().createMethod(),
		};
		return answer;
	}

	@Override
	public FullyQualifiedJavaType[] produceImportClass() throws CompilationException {
		return new FullyQualifiedJavaType[]{
				JDKFullyQualifiedJavaType.getArrayListInstance()
		};
	}
}
